<?php
/*
cmfit
Copyright (C) 2000-2007 Andreas Bengtsson

Email: anteman@users.sourceforge.net

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

// Andreas Bengtsson 2000-05-29
// 
// delbbs.php a bounce page to delete bbs files
//
// -------------------------------------------------------------
// post or get variables;
// filename
// currdir



//###TODO
// check if the bbs file itself had a bbs directory+files
// check if the bbs file had image tags, if so remove images as well

require('functions.php');
require('config.php');

$delcurrdir=rawurldecode($delcurrdir);
$delfilename=rawurldecode($delfilename);

// Cludge to make the browser reload the new page with the correct bbs entries
// by using a unique GET syntax url.
srand ((double) microtime() * 1000000);
$randval = rand();
$cachedummy="dummy".$randval;

?>
<HTML>
<HEAD>
<TITLE>Delete...</TITLE>
<SCRIPT>
function fin(){
 document.location='<? echo "editor.php?filename=".$filename."&currdir=".$currdir."&cachedummy=".$cachedummy; ?>';
 //('<? echo "editor.php?filename=".$filename."&currdir=".$currdir; ?>');
}
</SCRIPT>
</HEAD>
<BODY>
Deleting "
<? 
echo "$delcurrdir$delfilename\"<BR>\n";

$problems=false;

if(file_exists($c_templatedir.$delcurrdir.$delfilename.".content")){
	if(unlink($c_templatedir.$delcurrdir.$delfilename.".content")){
		?>
		Content file deleted.<BR>
		<?
	}else{
		$problems=true;
	}
}
if(file_exists($c_livedir.$delcurrdir.$delfilename)){
	if(unlink($c_livedir.$delcurrdir.$delfilename)){
		?>
		Live file deleted.<BR>
		<?
	}else{
		$problems=true;
	}
}
if(file_exists($c_templatedir.$delcurrdir.$delfilename)){
	if(unlink($c_templatedir.$delcurrdir.$delfilename)){
		?>
		File deleted.<BR>
		<?
	}else{
		$problems=true;
	}
}

if($problems==true){
 ?>
	Something went wrong.<BR>
 <?
}

?>
<BR>
<A HREF="javascript:fin()">Go back.</A>
<BR>Remember to submit the main page where this deleted posting was referred to,
that is currently the way to update the live systems main page.
</BODY>
</HTML>
